/**
 * author      : dormi330
 * date        : 2018/6/27
 * project     : mybatis
 * description : TODO
 */

package org.wzq.learn.domain.order;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.wzq.learn.infrastructure.persist.mybatis.OrderDeliveryMapper;
import org.wzq.learn.infrastructure.persist.mybatis.OrderItemMapper;
import org.wzq.learn.infrastructure.persist.mybatis.OrderSummaryMapper;
import org.wzq.learn.infrastructure.persist.mybatis.TradeOrderMapper;

import java.util.List;

@Repository
public class OrderQueryRepository {

    @Autowired
    private TradeOrderMapper tradeOrderMapper;

    @Autowired
    private OrderSummaryMapper orderSummaryMapper;

    @Autowired
    private OrderDeliveryMapper orderDeliveryMapper;

    @Autowired
    private OrderItemMapper orderItemMapper;

    // 查询单个 OrderSummary
    public OrderSummary orderSummaryOfId(String tenantCode, String orderSummaryId) {
        return orderSummaryMapper.queryById(tenantCode, orderSummaryId);
    }

    // 查询 OrderSummary 对应的 TradeOrder
    public List<TradeOrder> tradeOderOfOrderSummary(String tenantCode, String orderSummaryId) {
        return tradeOrderMapper.queryByOrderSummaryId(tenantCode, orderSummaryId);
    }

    // 查询单个 TradeOrder
    public TradeOrder getTradeOrder(String tenantCode, String tradeOrderId) {
        return tradeOrderMapper.queryById(tenantCode, tradeOrderId);
    }

    // 查询用户的所有订单列表
    public List<OrderSummary> orderSummaryOfMember(String tenantCode, String memberId) {
        return orderSummaryMapper.queryByMember(tenantCode, memberId);
    }

    // 查询 trade order 的 orderItem
    public OrderItem orderItemOfTradeOrder(String tenantCode, String tradeOrderId) {
        return orderItemMapper.queryByTradeOrder(tenantCode, tradeOrderId);
    }

    // 查询 trade order 的 orderDeliveryO
    public OrderDelivery orderDeliveryOfTradeOrder(String tenantCode, String tradeOrderId) {
        return orderDeliveryMapper.queryByTradeOrder(tenantCode, tradeOrderId);
    }

}
